<!--车辆处置页面-->
<template>
  <div>
    <el-dialog
      title="详情"
      :visible.sync="dialogVisible"
      width="80%"
      v-if="formData"
      @close="close"
    >
      <el-form :model="formData" label-width="150px" ref="form">
        <el-row>
          <el-col :sm="12">
            <el-form-item label="单位名称">{{formData.company.companyName}}</el-form-item>
          </el-col>
          <el-col :sm="12">
            <el-form-item label="处置方式">{{formData.clname}}</el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :sm="24">
            <el-form-item label="附件">
              <a style="color:blue" @click="download(formData.fileurl,formData.filename)">{{formData.filename}}</a>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row style="margin-top:20px;">
          <el-col :sm="24">
            <el-form-item label="处置车辆">
              <el-table :data="formData.cardisposecars" style="width: 100%" size="mini" border>
                <el-table-column type="index" label="序号" width="80" align="center"></el-table-column>
                <el-table-column prop="car.carCode" label="车牌号" align="center"></el-table-column>
                <el-table-column prop="car.pinpai" label="品牌" align="center"></el-table-column>
                <el-table-column prop="car.carColor" label="颜色" align="center"></el-table-column>
                <el-table-column prop="car.useType" label="使用性质" align="center"></el-table-column>
              </el-table>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-form-item label="历史流程">
            <el-table :data="history" style="width: 100%" size="mini" border>
              <el-table-column prop="taskName" label="步骤" align="center"></el-table-column>
              <el-table-column prop="userName" label="审核人" align="center"></el-table-column>
                <el-table-column prop="mobile" label="电话" align="center"></el-table-column>
              <el-table-column prop="mark" label="审批意见" align="center"></el-table-column>
              <el-table-column prop="passStr" label="状态" align="center"></el-table-column>
              <el-table-column prop="optime" label="操作时间" align="center"></el-table-column>
            </el-table>
          </el-form-item>
        </el-row>
      </el-form>
      <span slot="footer" class="dialog-footer" style="text-align: left;">
        <el-button @click="close">关闭</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import { viewJson} from "@/api/task";
import { dateFormat } from "@/utils/utils";
export default {
  data() {
    return {
      pass: 1,
      opData: null,
      history: [],
      formData: null,
      dialogVisible: false,
    };
  },
  created() {
    this.webUploadUrl = this.VUE_APP_BASE_API + "/common/webupload.shtml";
  },
  methods: {
    close() {
      this.dialogVisible = false;
    },
    /**
     * @description 查看任务
     * @param opData 当前操作的任务原始数据 list接口返回的
     */
    async viewTask(opData) {
      this.opData = opData;
      let params = {
        tableId: opData.id,
        pid: opData.prcid,
       // taskId: opData.taskId,
        formKey: "carcz_ss"
      };
      let taskDetail = await viewJson(params);
      if (taskDetail.data.cardisposecars && taskDetail.data.cardisposecars[0]) {
        for (let key in taskDetail.data.cardisposecars[0]) {
          if (key.startsWith("file")) {
            taskDetail.data[key] = taskDetail.data.cardisposecars[0][key];
          }
          if (key.startsWith("fileurl")) {
            if (taskDetail.data.cardisposecars[0][key]) {
              let filenameKey = "filename" + key.substring(key.length - 1);
              taskDetail.data[key + "list"] = [
                {
                  name: taskDetail.data.cardisposecars[0][filenameKey],
                  url: taskDetail.data.cardisposecars[0][key]
                }
              ];
            } else {
              taskDetail.data[key + "list"] = [];
            }
          }
        }
        taskDetail.data.pmgs = taskDetail.data.cardisposecars[0].pmgs;
      } else {
        this.$message({
          message: "没有车辆数据",
          type: "error"
        });
        return;
      }
      this.formData = taskDetail.data;
      this.formData.fileurl = this.VUE_APP_BASE_API + this.formData.fileurl;
      this.history.splice(0, this.history.length, ...taskDetail.history);
      this.dialogVisible = true;
    },
  }
};
</script>
<style lang="scss" scoped>
.el-timeline {
  position: relative;
  top: -25px;
  left: 110px;
  margin-bottom: -45px;
}
</style>
<style lang="scss">
.upload-mini {
  .el-upload-dragger {
    height: 50px;
    line-height: 50px;
  }
}

.upload-mini + .el-form-item__error {
  position: relative;
  top: -15px;
}
</style>
<style lang="scss" scoped>
.el-timeline {
  position: relative;
  top: -55px;
  left: 110px;
  margin-bottom: -45px;
}
</style>